from sqlalchemy import Column, Integer, String, Enum as SQLAlchemyEnum
from sqlalchemy.orm import declarative_base
import enum

Base = declarative_base()

class SongStatus(str, enum.Enum):
    PENDING = "pending"
    DOWNLOADING = "downloading"
    AVAILABLE = "available"
    ERROR = "error"

class Song(Base):
    __tablename__ = "songs"

    id = Column(Integer, primary_key=True, index=True)
    title = Column(String(255), index=True, nullable=False)
    artist = Column(String(255), index=True, nullable=True)
    source_url = Column(String(512), unique=True, nullable=False)
    file_path = Column(String(512), nullable=True)
    status = Column(SQLAlchemyEnum(SongStatus), nullable=False, default=SongStatus.PENDING)
    # 根据需要添加其他字段，如时长、缩略图URL等 